<?php
require_once(dirname(__FILE__)."/../../libs/login/login.php");  
require_once(dirname(__FILE__)."/../../libs/dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../../admin/libs/power_class.php");
$lg=new login();
$lg->checklogin("admin_member");//检验是否登录
$mc=new libstr();
$pw=new power();
$id=$_GET["id"]?$_GET["id"]:0;
$path="菜单管理";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理系统</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/JavaScript" src="../../plug/mmTree/tree/jQuery1.6.2.js"></script>
<link rel="STYLESHEET" type="text/css" href="tree/dhtmlxtree.css">
<script  src="../../plug/mmTree/tree/dhtmlxcommon.js"></script>
<script  src="../../plug/mmTree/tree/dhtmlxtree.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	
  tree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
  tree.setSkin('dhx_skyblue');//加载树结构的图标
  tree.setImagePath("../../plug/mmTree/tree/imgs/csh_bluefolders/");//设置是否允许显示树图片
  tree.enableTreeImages(0);//1 - on, 0 - off
  tree.enableDragAndDrop(true);
  tree.enableCheckBoxes(true);
  
 //  允许三种状态的复选框（全选、不选、部分选中）
  tree.enableThreeStateCheckboxes(1)// 1 - on, 0 - off;
  tree.enableTreeLines(false);
  tree.setOnRightClickHandler(function(id){
    tree.selectItem(id);
    $("#mm").val(id);
  });

 var id=tree.getFileTreeNowId();
// tree.setXMLAutoLoading("powerxml.php?mid=<?php echo $id;?>");
  tree.loadXML("menuxml.php?id=0&mid=<?php echo $id;?>"); //设置是否显示树线
  tree.enableTreeLines(1);//设置是否允许IE缓存
  tree.preventIECashing='disable';//mode - enable/disable random seed ( disabled by default )
  
	$("#pwset").click(function(){
		var tt=tree.getAllChecked();
		//alert(tt);
		if(tt==""){
			alert("请选择菜单！");	
			return;
		}
		$.ajax({ 
			type: "POST", 
			url: "../ajax/inc.php", 
			dataType: "text", 
			data: {"menubtn":true,"id":<?php echo $id;?>,"val":tt}, 
			beforeSend: function(){ 
		  
			}, 
			success: function(data){
				 if(data.indexOf("update is ok")!=-1){
					alert("后台菜单设置成功！");
					location.href="power_class.php";
				}		
 			}
		})
	})

});

</script>

</head>
<body style="background:#fff"> 
<div class="content" >
    <div class="right" >
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
          <td width="100%" height="24" class="top_head">&nbsp;</td>
          </tr>
          <tr>
            <td valign="top">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="1%" align="right"  height="45">&nbsp;</td>
                    <td width="99%" >
                     <table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="55%" style="padding-left:20px;padding-top:10px;"><img src="../images/head.gif" width="13" height="11"><b><?php echo $path;?></b><a href="powercontent_class_creat.php?classid=<?php echo $_GET["classid"]?>" style=" margin-left:20px; text-decoration:underline;">添加新类</a></td>
                        <td width="45%" align="right">&nbsp;</td>
                      </tr>
                    </table>
                    </td>
                  </tr>
                </table>
            </td>
          </tr>	
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="bg">
              <tr>
                <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"  class="line">
                  <tbody>
                
                  </tbody>
                </table>
                </td>
              </tr>
            </table>
            </td>
          </tr>
        </table>
        <div class="tree">
            <p> <h3>后台菜单设置：</h3>   </p>
             <div id="treeboxbox_tree" style="width:620px; height:auto;font-size:14px; margin-top:10px" ></div>
                 <p><input name="pwset" type="button" value="设置" id="pwset"  class="czbtn"></p>
             </div>
        </div>
	</div>
	</form>
</body>
</html>